const fs = require('fs')
const path = require('path')

const writeTo = (filename, data) => {
	if (!data) {
		throw new Error('请输入数据');
	}
	fs.writeFile(filename, JSON.stringify(data), 'utf-8', err => {
		if (err) throw err;
		console.log('---- 文件已保存')
	})
}

module.exports = {
	writeTo,
}
